package com.binarysearch;

import java.util.Arrays;
import java.util.Comparator;
import java.util.TreeMap;

public class Solution367 {
    public boolean isPerfectSquare(int num) {
        int i = 1;
        int j = num;
        while (i <= j) {
            int mid = (i + j) >> 1;
            if (mid * mid == num) return true;
            else if (mid * mid < num) i = mid + 1;
            else j = mid - 1;
        }
        return false;
    }
}
